"""
mysql数据库链接
"""
from pymysql import Connection

conn = Connection(
    host='localhost',
    port=3306,
    user='root',
    password='123456',
    autocommit=True  # 自动确认
)

print(conn.get_server_info())

cursor = conn.cursor()
conn.select_db("book")
cursor.execute('select * from blog')
results: tuple = cursor.fetchall()
for r in results:
    print(r)

conn.close()
